(function() {
	
	hfrApp.factory("HfrConfig", function ($rootScope) {
		return {
			ApiServiceUrl: {
		                customersUrlApi: "http://server-harforent.appspot.com/api/customers", //server-harforent.appspot.com
		                blogsUrlApi : "http://server-harforent.appspot.com/api/blogs",
		                topicsUrlApi: "http://server-harforent.appspot.com/api/topics",
		                sitemapsUrlApi: "http://server-harforent.appspot.com/api/sitemaps",
		                blogTopicsUrlApi: "http://server-harforent.appspot.com/api/blog-topics",
		                selectorsUrlApi: "http://server-harforent.appspot.com/api/selectors",
		                postSuccessUrlApi: "http://server-harforent.appspot.com/api/post-success",
		                checkPostUrlApi: "http://server-harforent.appspot.com/api/check-posts",
		                checkPreviewSelectorApi: "http://server-harforent.appspot.com/api/previewSelectors",
		            },
			GooglePlus: {
				clientId: "804599464095-dtb3e4utgdhp6phccd9sj8b1gf50anv7.apps.googleusercontent.com",
			},
			displayMeta: function (name) {
				var metaInfo = $rootScope.hfrMeta[name];
				$rootScope.metaTitle = metaInfo.title;
				$rootScope.metaDescription = metaInfo.description;
				$rootScope.metaKeyword = metaInfo.keyword;
				
				return this;
			}
		}
	});
	
	hfrApp.factory("HfrGlobal", function ($rootScope) {
		return {
			set: function (name, val) {
				eval("$rootScope." + name) = val;
				$window.localStorage && $window.localStorage.setItem(name, val);
				return this;
			},
			get: function (name) {
				
				if (eval("$rootScope." + name) === undefined) {
					return $window.localStorage && $window.localStorage.getItem(name);
				} else {
					return eval("$rootScope." + name);
				}
			}
		}
	});
	
	//Storage and get data
	hfrApp.factory("HfrStorage", function ($window, $rootScope) {
		return {
			set: function(name, val) {
				$window.localStorage && $window.localStorage.setItem(name, val);
				return this;
			},
			get: function(name) {
				return $window.localStorage && $window.localStorage.getItem(name);
			},
			remove: function(name) {
				$window.localStorage && $window.localStorage.removeItem(name);
				return this; 
			},
			clearAll: function() {
				$window.localStorage && $window.localStorage.clear();
				return this;
			}
		}
	});
	
	//Init 
	hfrApp.factory("HfrInit", function ($rootScope) {
		return {
			message: function () {
				$rootScope.message = {
					success	: 	false,
					error	:	false,
					text	:	""
				};
				return this;
			}
		}
	});
	
	hfrApp.run(function (HfrConfig) {
		//$rootScope.customerId = "hoantocxoan@hatforrent.website";
	});
	
})();